package io.renren.modules.app.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.app.dao.ActionSettingsDao;
import io.renren.modules.app.entity.ActionSettingsEntity;
import io.renren.modules.app.service.ActionSettingsService;


@Service("actionSettingsService")
public class ActionSettingsServiceImpl extends ServiceImpl<ActionSettingsDao, ActionSettingsEntity> implements ActionSettingsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ActionSettingsEntity> page = this.page(
                new Query<ActionSettingsEntity>().getPage(params),
                new QueryWrapper<ActionSettingsEntity>()
        );

        return new PageUtils(page);
    }


    @Override
    public ActionSettingsEntity getActionSettings() {
        QueryWrapper<ActionSettingsEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("setting_type",1);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

}